'''
Created on Jul 27, 2011

@author: vijayp
'''
import unittest
import datetime
from qif import qif, shares_qif_entry, AperioCSVImporter


class Test(unittest.TestCase):
  def testSimpleQIF(self):
    q = qif('name', 'Invst')
    e = shares_qif_entry(date_obj=datetime.date.today(),
                         is_xfer_in=True,
                         security_name='Google',
                         quantity=100)
    q.add_entry(e)
    assert q.str() == '''!Account
Nname
TInvst
^
!Type:Invst
^
Cc
D27 July 2011
MGoogle
NShrsIn
Q100
YGoogle'''

  def testAperioCSV(self, fn='test.csv'):
    q = qif('name', 'Invst')
    AperioCSVImporter.import_to_qif(fn, q)
    assert q.str() == '''!Account
Nname
TInvst
^
!Type:Invst
^
Cc
D29 October 2008
MAPPLE COMPUTER INC
NShrsIn
Q20
YAPPLE COMPUTER INC'''

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()
